﻿//var whi = 1000 * 1000;

//stopwatch.start("pop");
//var b = new ValuesSet();
//b.add(1);
//b.add(2);
//b.add(3);

//for (var i = 0; i < whi; i++) {
//    //var arr = [4, 5, 9, 3, 2];
//    //arr.selectSort();
//    //var e = b.add(i);
//    b.add(1);
//    b.remove(1);

//    var x = b[2];

//    //if (b[5])
//    //    var x = 2;
//}

//$('body').prepend(stopwatch.end("pop"));

//stopwatch.start("splice");
//var a = new ValuesSet3();
//a.add(1);
//a.add(2);
//a.add(3);
//for (var i = 0; i < whi; i++) {
//    //var arr2 = [4, 5, 9, 3, 2];
//    //quickSort(arr2);
//    //var e = a.add2(i);
//    a.add(1);
//    a.remove(1);

//    var z = a.has[2];
//    //var z = a.getValues();
//    //if (a.arrMask[5])
//    //    var x = 2;
//}

//$('body').prepend(stopwatch.end("splice"));


$(function () {






    //    gridModel = new GridModel();
    //716-92-5-839456--754281-9-626-9-5741951-----33742-169---5--93--6235-8--9-9--2--6-
    //--9--8--6-6--3--9-7--6--4--4--7--5---7--5--24--5--4--8--63-1--2-3--2--6-8--9--3--
    //--5-1-46-3--49-5--64------7-------2-17--5--34-9-------2-4----7--56-32-48-1--4-2--
    //-75-469-834629817589--57-4676952481352387146941896375263-48259-98--15--4-54-39-8-
    //--9--2374--4-7-59-7--9-4--1861349257-9-7614384378251699--4-7--3-7----94--4829-715 (pointing pair)
    //--54--6-2--6-2-15-293561784-523-48--3-12-64-5----5732--3--4256--24--59--5-7--924- (x wing rows)
    //1---9---5-8-4-6-9--97--56---7-548-2-2--96---4-4-1-2-5---97--8---2-6-95177---5---9 (swordfish rows)
    // gridModel = GridModel.fromShortString("--7-836---397-68--82641975364-19-387-8-367----73-48-6-39-87--267649--1382-863-97-");
    // ori 123456789456789123789123456234567891567891234891234567345678912678912345912345678
    //gridModel = Generator.createNew();
    gridModel = GridModel.fromShortString("--7---2-652-1---3-4-87-------3-1--9---6-2-5-17------6------3-------4-9---7-8--3--");
    // gridModel.cells[0][0].candidates.add(3);
    //  gridModel = gridModel.getBaseGrid();
    var solver = new Solver(Strategies.getAll());
    SolvingHelper.fillCandidates(gridModel);
    var strat = solver.solve(gridModel);
    console.log(strat.performedResults.map(function (elm) { return elm.strategy; }));
    //SudokuGrid.loadNewGrid(gridModel);
    //var models = [];
    //var repeat = 1;
    //for (var rep = 0; rep < repeat; rep++) {

    //    models[rep] = gridModel.getBaseGrid();
    //    SolvingHelper.fillCandidates(models[rep]);
    //    //  solver.solve(models[rep]);
    //}

    //var ns = new Strategies.SimpleColoring();

    //var modelsstr = ObjectSerializer.serialize(models);

    //window.doit = function () {

    //    var gridui = $('.grid').data('grid');
    //    models = ObjectSerializer.deserializeRoot(modelsstr);

    //    $('body').prepend("<br>");
    //    stopwatch.start(" a");
    //    var generator = new Generator();
    //    //console.profile('wata');
    //    for (var rep = 0; rep < repeat; rep++) {

    //        //  gridui.onGridFill(null, SudokuGrid);

    //        gridModel = models[rep];
    //        //solver.solve(gridModel);
    //        //BackTrakingSolver.solve(gridModel, solverOptions);

    //        gridModel = generator.createNew(Levels.Easy);

    //        //for (var i = 0; i < 1; i++) {
    //        //    ns.perform(gridModel);
    //        //    // ns.perform(gridModel);
    //        //    // gridui.onGridFill(null, SudokuGrid);
    //        //    //SolvingHelper.getEmptyCells(gridModel.cells[0]);
    //        //    //gridModel.updateValuesIndex();
    //        //}

    //        //}

    //    }
    //    //console.profileEnd('wata');

    //    $('body').prepend(stopwatch.end(" a"));
    //    SudokuGrid.loadNewGrid(gridModel);

    //}


    // $('body').on('click', window.doit)
});